const { createProxyMiddleware } = require('http-proxy-middleware');
// console.log('httpProxyMiddleware',httpProxyMiddleware)
const express = require('express');

// 目标服务器的 IP 和端口
const targetIp = '192.168.100.10';
const targetPort = 20000;

// 创建 Express 应用
const app = express();

// 设置代理中间件
app.use(createProxyMiddleware({
    target: `http://${targetIp}:${targetPort}`,
    changeOrigin: true,
}));

// 启动代理服务器
const port = 9001;
app.listen(port, () => {
    console.log(`Proxy server is running on http://localhost:${port}`);
});